#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 1e5 + 10, INF = 0x3f3f3f3f;

ll n, z[N];
string s;


void get_z()
{
    z[0] = n;
    ll mid, mr = 0;
    for (ll i = 1;i < n;i++) {
        ll len = i < mr ? min(z[i - mid], mr - i) : 0;
        while (i + len < n && s[i + len] == s[len]) len++;
        if (i + len > mr) mr = i + len, mid = i;
        z[i] = len;
    }
}

void solve()
{
    while (cin >> s) {
        memset(z, 0, sizeof z);
        n = s.length();
        get_z();

        ll ans = 0;
        for (ll i = 1;i < n;i++)
            ans += z[i] * (z[i] + 1) / 2;
        cout << ans << '\n';
    }
}

signed main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}